<!DOCTYPE html>
<html lang="en">
	<head>
    	<meta name="layout" content="main_pc">
        <title>火堆</title>       
        <link rel="stylesheet" href="${resource(dir: 'css', file: 'user.center.css')}" type="text/css">
    </head>
<body>

	<div class="container-fluid">

		<section class="quick-navi mb20">
			<div class="container">
				<a href="#" class="quick-link"><span>我的工作台</span><span
					class="caret"></span></a>
				<!--a href="#" class="quick-link">联系我们</a-->
			</div>
		</section>

		<section>
			<div class="container mb50">
				
				<div class="left-navi">
					<div class="module-list">
		
						<sec:ifAnyGranted roles="ROLE_USER,ROLE_ADMIN">
							<div class="module-title">
								<span class="icon data"></span>我的项目
							</div>
							<a class="module-link active" href="/scfire/project/index">项目信息</a>
							<a class="module-link" href="/scfire/project/create">创建项目</a>							
						</sec:ifAnyGranted>
						
						<sec:ifAnyGranted roles="ROLE_ADMIN">
							<div class="module-title">
								<span class="icon cube"></span>项目管理
							</div>
							<a class="module-link" href="/scfire/manage/projectApproveStatus?status=wait">待审核</a>
							<a class="module-link" href="/scfire/manage/projectApproveStatus?status=pass">审核通过</a>
							<a class="module-link" href="/scfire/manage/projectApproveStatus?status=refuse">审核拒绝</a>							
						</sec:ifAnyGranted>
						
						<sec:ifAnyGranted roles="ROLE_USER,ROLE_ADMIN">
							<div class="module-title">
								<span class="icon user"></span>个人中心
							</div>
							<a class="module-link" href="">基本资料</a>
							<a class="module-link" href="">密码修改</a>
							<a class="module-link" href="">实名认证</a>							
						</sec:ifAnyGranted>
						    
					</div>
				</div>				
				
				
				<div class="right-content" id="rightconsole">                   
                    <div class="data-list-box">                        
                        <ul class="cdsp-table">
                            <li class="t-head">
                               <div class="col-1"></div>
                                <div class="col-2">项目名称</div>
                                <div class="col-4">描述</div>
                                <div class="col-3">创建时间</div>
                                <div class="col-2">是否认证</div>
                                <div class="col-2">首页显示</div>
				<div class="col-6">操作</div>
                                <div class="clearboth"></div>
                            </li>
                             
                            <g:each in="${projects}" var="${project}" status="i">
                            	<li>
                            		<div class="col-1">
                                     <div class="title">${i+1}</div>
                                 </div>
                                  <div class="col-2">
                                     <div class="title">${project.name}</div>
                                 </div>
                                 <div class="col-4">
                                     <div class="text">${project.description}</div>
                                 </div>
                                 <div class="col-3">
                                     <div class="text">
                                     <g:formatDate format="yyyy-MM-dd" date="${project.createDate}"/>
                                     </div>
                                 </div>
                                 <div class="col-2">
                                     <div class="text">
                                     <g:if test="${project.verified==false}">未认证</g:if><g:else>
                                     	已认证
                                     </g:else>
                                     </div>
                                 </div>
                                 
                                
                                 
                                 
                                 <div class="col-2">
                                     <div class="text">
                                   <%findflag = false%>
                                  <g:each in="${homes}" var="${home}" status="j">
                                  	<g:if test="${home.project == project}">
                                  		<input type="checkbox" id="status_${project.id}" checked="checked"/>
                                      	<input type="text" id="position_${project.id}" onkeyup="correctInputNum(this)" value="${home.position}" size="1"/>
                                      	<%findflag = true%>
                                  	</g:if>
                               </g:each>
                               <g:if test="${findflag != true}">
                                      	<input type="checkbox" id="status_${project.id}" />
                                      	<input type="text" id="position_${project.id}" onkeyup="correctInputNum(this)" value="" size="1"/>
                                  </g:if>
                                     </div>
                                 </div>
                                 
                                 
                                 <div class="col-6">
                                 	<g:link controller="project" action="show" id="${project.id}" target='_blank'><div class="btn btn-check btn-white" data-dialog="dialog1">查看</div></g:link>
                                 	<g:link controller="project" action="edit" id="${project.id }"><div class="btn btn-check btn-white" data-dialog="dialog1">更新</div></g:link>
                                     <a href="#" data-toggle="modal" data-target="#alert" onclick="changeHref('${project.id}')" ><div class="btn btn-check btn-white" data-dialog="dialog1">删除</div></a>
                                     <a href="#" data-toggle="modal" data-target="#alert_Home" onclick="changeHome('${project.id}')" ><div class="btn btn-check btn-white">推送</div></a>
                                 </div>
                                 <div class="clearboth"></div>
                            	</li>
                            </g:each>
                        </ul>
                    </div>
                    
                    <div class="pagea">
	                <span>共${count ?: 0}条记录</span>
	                <div class="page float_r">
						<g:paginate controller="project" action="index" total="${count ?: 0}"/>
					</div>
            		</div>		            	                            
               	</div>
               	
               	
			</div>
			<div class="clearboth"></div>
		</section>


	</div>

<!-- 删除弹出框 -->
		<div class="modal fade" id="alert">
			<div class="modal-dialog" style='margin-top:200px;'>
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
						<h4 class="modal-title">提示</h4>
				</div>
				
				<div class="modal-body">
					<font size='5px'>
						<p>您确定要删除吗？</p>
					</font>
				</div>
				
				<div class="modal-footer" style="text-align:left">
					<a href="#" class="btn btn-primary" id='data_del'>删除</a>
					<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
				</div>
				
				</div><!-- /.modal-content -->
			</div><!-- /.modal-dialog -->
		</div><!-- /.modal -->
		
		<div class="modal fade" id="alert_Home">
			<div class="modal-dialog" style='margin-top:200px;'>
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
						<h4 class="modal-title">提示</h4>
				</div>
				
				<div class="modal-body">
					<font size='5px'>
						<p>确定推送吗？</p>
					</font>
				</div>
				
				<div class="modal-footer" style="text-align:left">
					<a href="#" class="btn btn-primary" id='data_home'>推送</a>
					<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
				</div>
				
				</div><!-- /.modal-content -->
			</div><!-- /.modal-dialog -->
		</div><!-- /.modal -->


	<script type="text/javascript">
		$(function() {

			$('ul.nav.navbar-nav li').hover(
					function() {
						console.log($(this).index());
						$(this).siblings('.top-active').addClass(
								'position-' + $(this).index());
					},
					function() {
						$(this).siblings('.top-active').removeClass(
								'position-' + $(this).index());
					});



		})

		function showSubTypeList(id) {
			$(id).fadeIn(150).siblings('.sub-type-list').hide();
		}
		function changeHref(id){
			var dataapi_del = $("#data_del");
			dataapi_del.attr("href","/scfire/project/delete/"+id);
        }

		function changeHome(id){
			var data = $("#data_home");
			var position = $("#position_"+id).val();
			var status;
			if($("#status_"+id).is(":checked")){
				status = 1;
			}
			else{
				status = 0;
			}
			console.log("status: "+ status);
			console.log("position: "+ position);
			data.attr("href","/scfire/project/updateHome?pid="+id+"&position="+position+"&status="+status);
        }

        function getStatus(value, index){
            var position = $("#homes_ps_"+value).val();

            if(position == null){
                return
            }
            
        	$("#position_"+value).val(position);
			$("#status_"+value).val('TRUE');
        }

        function correctInputNum (obj) {
            var v = correctNum($(obj).val());
            if (v == '') {
                $(obj).val('1');
            } else {
                $(obj).val(v);
            }
        }
        function correctNum (num) {
            return (num + '').replace(/\D/g, '');
        }
	</script>

</body>
</html>